package panel.viewSpots.navigationNew
{
	import assists.resource.ResourceLoader;
	
	import com.greensock.TimelineLite;
	import com.greensock.TweenLite;
	
	import flash.display.Bitmap;
	import flash.display.Sprite;
	
	public class WCItem extends Sprite
	{
		private var _loader:ResourceLoader;
		
		private var _circle:Sprite = new Sprite();

		private var timeLine:TimelineLite;
		public function WCItem(loader:ResourceLoader)
		{
			_loader = loader;
			init();
		}
		
		private function init():void
		{
			var ball:Bitmap = _loader.uiManager.generateBmp(_loader.uiManager.navigationBallPng,true);
			ball.x = - ball.width * 0.5;
			ball.y = - ball.height * 0.5;
			
			var bmp:Bitmap = _loader.uiManager.generateBmp(_loader.uiManager.navigationCirclePng,true);
			bmp.x = - 0.5 * bmp.width;
			bmp.y = - 0.5 * bmp.height;
			_circle.addChild(bmp);
			
			this.addChild(_circle);
			this.addChild(ball);
			playCartoon();
		}
		
		private function playCartoon():void
		{
			_circle.scaleX = _circle.scaleY = 0.1;
			_circle.alpha = 1;
			timeLine = new TimelineLite();
			timeLine.append(new TweenLite(_circle,2,{alpha:0,scaleX:0.7,scaleY:0.7,onComplete:callBack}));
//			timeLine.append(new TweenLite(_circle,2,{alpha:1,scaleX:0.1,scaleY:0.1,onComplete:playCartoon}));
//			timeLine.resume();
//			timeLine.restart();
		}
		
		private function callBack():void
		{
			_circle.scaleX = _circle.scaleY = 0.1;
			_circle.alpha = 1;
			timeLine.restart();
		}
		
		public function update():void
		{
			if(this.visible)
			{
				playCartoon();
			}else
			{
			timeLine.clear();
			}
		}
		
	}
}